import React from 'react'

import Child1 from './child1.jsx'
import Child2 from './child2.jsx'

// 人民币和美元之间相互转换？
export default class child1 extends React.Component{
    constructor(){
        super()
        this.state={
            RMBmoney:1,
            USAmoney:7
        }
    }

    RmbChange=(e)=>{
        this.setState({
            RMBmoney:e.target.value,
            USAmoney:e.target.value*7
        })
    }
    USAChange=(e)=>{
        this.setState({
            RMBmoney:e.target.value/7,
            USAmoney:e.target.value
        })
    }
    componentDidMount(){
        console.log(this.money);
    }
    render(){
        return(
            <div>
                <p>这是父级组件</p>
                <Child1 moneyChange={this.RmbChange} money={this.state.RMBmoney}/>
                <Child2 moneyChange={this.USAChange} money={this.state.USAmoney}/>
            </div>
        )
    }
}